<?php

class Log{
    public static function write($context){
        //日志文件
        $filename=__DIR__."/log.txt";
        
        $handle=fopen($filename,"a+");
        $str=fwrite($handle,"{$context}\n");
        fclose($handle);
    }

    public static function run($context){
        //运行缓存文件
        $filename=__DIR__."/runtime.txt";

        $handle=fopen($filename,"w");
        $str=fwrite($handle,$context);
        fclose($handle);
    }

    public  static function get(){

        $wl_dir=__DIR__.'/runtime.txt';

        if(file_exists($wl_dir)){
            $fp = fopen($wl_dir,"r");
            $str = fread($fp,filesize($wl_dir));//指定读取大小，这里把整个文件内容读取出来
            $str = str_replace("\r\n","<br />",$str);

//            $arr=explode(',',$str);
//
//            $info_arr=[];
//            foreach ($arr as $item) {
//                $temp=explode(':',$item);
//                $info_arr[$temp[0]]=$temp[1];
//            }
//            var_dump($info_arr);
            return $str;

        }
    }

}
